#!/usr/bin/env python
# -*- encoding: utf-8 -*-
"""
@File        :   232.用栈实现队列.py    
@Contact     :   lhouctcs@163.com
@License     :   MIT
@Time        :   2023/2/10 17:34
@Author      :   lhou 
@Version     :   0.1.0
@Description :
"""


# import lib
class MyQueue:

    def __init__(self):
        self.s_in = []
        self.s_out = []

    def push(self, x: int) -> None:
        self.s_in.append(x)

    def pop(self) -> int:
        if self.empty(): return None
        if self.s_out:
            return self.s_out.pop()
        else:
            for i in range(len(self.s_in)):
                self.s_out.append(self.s_in.pop())
            return self.s_out.pop()

    def peek(self) -> int:
        ans = self.pop()
        self.s_out.append(ans)
        return ans

    def empty(self) -> bool:
        return not (self.s_in or self.s_out)

# Your MyQueue object will be instantiated and called as such:
# obj = MyQueue()
# obj.push(x)
# param_2 = obj.pop()
# param_3 = obj.peek()
# param_4 = obj.empty()
